package form;
import java.util.HashMap;

/**
 * A hashMap of valid field Types. 
 * @author simon
 */
public class FieldTypes {

    private HashMap<String, FieldType> fieldTypes;

    /**
     * Create a hashMap of fieldTypes we have availible. 
     */
    public FieldTypes(){
        fieldTypes = new HashMap<String, FieldType>();
        for(FieldType t: FieldType.values()){
            fieldTypes.put(t.toString(), t);
        }
    }

    /**
     * Returns the field asked for or null
     * @param type
     * @return field or null
     */
    public FieldType getFieldType(String type){
        return fieldTypes.get(type.toLowerCase());
    }

    /**
     * check if a field is valid.
     * @param type
     * @return true or false
     */
    public boolean isFieldType(String type){
        return fieldTypes.containsKey(type.toLowerCase());
    }
}
